<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var a = [
      {
        id: 1,
        value: 1
      },
      {
        id: 2,
        value: "23"
      },
      {
        id: 3,
        value: 'hahah'
      }
    ];
    var b = [
      {
        id: 1,
        value: ["v1"],
        aa: '11'
      },
      {
        id: 3,
        value: 'v3'
      },
      {
        id: 4,
        value: 'v4'
      }
    ]
    const result = [
      {
        id: 1,
        value: [1, "v1"],
        aa: '11'
      }, {
        id: 2,
        value: "23"
      }, {
        id: 3,
        value: ['hahah', "v3"]
      },
      {
        id: 4,
        value: 'v4'
      }
    ];
    function testconxt(a, b) {
      let obj = {}
      a.forEach(item => {
        let xxx = {
          id: item.id,
          value: []
        }
        if (typeof (item.value) == 'object') {
          xxx.value.push(...item.value)
        } else {
          xxx.value.push(item.value)
        }
        obj[item.id] = xxx
      })
      b.forEach(e => {
        if (obj[e.id]) {
          if (typeof (e.value) == 'object') {
            console.log(...e.value);
            obj[e.id].value.push(...e.value)
          } else {
            obj[e.id].value.push(e.value)
          }
        } else {
          obj[e.id] = e
        }
      })
      let cc = []
      for (const key in obj) {
        cc.push(obj[key])
      }
      console.log(cc);
    }
    testconxt(a, b)
  </script>
</body>

</html>